const mongoose = require('mongoose')
const model = mongoose.model.bind(mongoose)
const Schema = mongoose.Schema

const userSchema = new Schema({
    email: {
        type: String,
        required: true
    },
    nickname:{
        type: String,
        required: true
    },
    password: {
        type: String,
        required: true
    },
    created_time: {
        type: Date,
        default: Date.now 
    },
    last_modified_time:{
        type: Date,
        default: Date.now
    },
    avatar:{
        type: String,
        default: '/public/'
    },
    bio:{
        type:String,
        default: ''
    },
    gender:{
        type: Number,
        enum: [-1,0,1],
        default: -1
    },
    birthday:{
        type: Date
    },
    status:{
        type:{
            // 0 没有权限限制
            // 1 不可以评论
            // 2 不可以登录
            enum: [0,1,2],
            default: 0
        }
    }
})

const User = model('User', userSchema)
module.exports =  User